import CommonBaseSchema from '#common/base_schema'

export default class extends CommonBaseSchema {
  protected tableName = 'wx_queues'

  async up() {
    this.schema.createTable(this.tableName, (table) => {
      table.increments()
      table.integer('fk_shop_id').notNullable().unsigned().references('shops.id').comment('店铺ID')

      table
        .integer('fk_member_id')
        .notNullable()
        .unsigned()
        .references('members.id')
        .comment('用户ID')

      table
        .integer('fk_queue_type_id')
        .notNullable()
        .unsigned()
        .references('dicts.id')
        .comment('排队类型')

      table.integer('fk_tony_id').nullable().unsigned().references('users.id').comment('服务人员')

      table.date('date').comment('服务日期')
      table.string('number', 20).comment('排队号码')
      table.tinyint('status').notNullable().defaultTo(1).comment('服务状态')
      table.integer('timer').defaultTo(0).comment('服务用时')
      table.string('memo').defaultTo('').comment('备注')

      this.defineCommonColumns(table)
      table.comment('微信小程序排队表')
    })
  }

  async down() {
    this.schema.dropTable(this.tableName)
  }
}
